package edu.ciee.tz.dao;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;

import edu.ciee.tz.model.User;

@Component("userDao")
public class UserDAO {
	public boolean checkPermission(User u){
		
		@SuppressWarnings("unchecked")
		List<User> users = hibernateTemplate.find(
				"from User u where u.name = '" + u.getName() + "' and u.password = '"+u.getPassword()+"'");
		
		if(users != null && users.size() > 0) {
			return true;
		}
		return false;
	}
	
	private HibernateTemplate hibernateTemplate; 

	public HibernateTemplate getHibernateTemplate() {
		return hibernateTemplate;
	}
	
	@Resource
	public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
		this.hibernateTemplate = hibernateTemplate;
	}
}
